<!DOCTYPE html>
<html lang="en" class="no-js" xmlns:th="http://www.thymeleaf.org">
<head>

    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- CSS -->
    <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' charset="utf-8">
    <link rel="stylesheet" th:href="@{/assets/css/reset.css}" >
    <link rel="stylesheet" th:href="@{/assets/css/supersized.css}">
    <link rel="stylesheet" th:href="@{/assets/css/style.css}" >
    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <title>酒店辅助订购系统-注册</title>

    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>
<body>
<center>
    <div class="page-container">
        <h2>用户注册</h2>
        <form action="/HTML/registerIn" method="post" >
            <input type="text" name="account"  placeholder="账号"  id="act" onkeydown="ableEdit()">
            <input type="password" name="password"  placeholder="密码"  id="pwd1" size="20" onkeydown="ableEdit()">
            <input type="password" name="passwordD"  placeholder="确认密码"  id="pwd2" size="20" onkeyup="validate()"/><span id="tishi3"></span>
            <button type="submit" id="submit" onclick="isNull()">注册</button>
            <button type="reset" value="重叠" onclick="cleantishi()">重置</button>
            <a href="/HTML/login"><input name="按钮" type="button" value="返回登录页"/></a>
        </form>
    </div>
</center>

<script type="text/javascript">
    function validate() {
        var pwd1 = document.getElementById("pwd1").value;
        var pwd2 = document.getElementById("pwd2").value;
        <!-- 对比两次输入的密码 -->
        if(pwd1 == pwd2) {
            document.getElementById("tishi3").innerHTML="<font color='green'>两次密码相同</font>";
            document.getElementById("submit").disabled = false;
        }
        else {
            document.getElementById("tishi3").innerHTML="<font color='red'>两次密码不相同</font>";
            document.getElementById("submit").disabled = true;
        }
    }
    function cleantishi() {
        document.getElementById("tishi3").innerHTML="";
    }

    function isNull() {

        var account =document.getElementById("act").value;
        var password =document.getElementById("pwd1").value;
        var cfPassword=document.getElementById("pwd2").value;

        if (account == "" || account == null ){
            document.getElementById("submit").disabled = true;
            alert("请填写账号")
        }
        else if(password == "" || password == null){
            document.getElementById("submit").disabled = true;
            alert("请先填写密码");
        }
        else if(cfPassword == "" || cfPassword == null){
            document.getElementById("submit").disabled = true;
            alert("请填写确认密码项");
        }
        else{

        }
    }
    window.onload=isSuccess();
    function isSuccess() {
        var flag=[[${flag}]];
     if(flag=="1"){
            document.getElementById("submit").disabled = true;
            alert("注册失败：用户名重复");
            window.location.href="/HTML/register";
        }
        else if(flag=="0"){
            alert("注册成功");
            document.getElementById("submit").disabled = false;
        }
        else{

     }
    }
    function ableEdit() {
        document.getElementById("submit").disabled = false;
    }
</script>
<script th:src="@{/assets/js/jquery-1.8.2.min.js}"></script>
<script th:src="@{/assets/js/supersized.3.2.7.min.js}"></script>
<script th:src="@{/assets/js/supersized-init.js}"></script>
<script th:src="@{/assets/js/scripts.js}"></script>
</body>
</html>